function [trimmedData,selector] = VectorTrimmer(t2H,VarsToTrim,n)

%This function eliminates the last few values from a data to avoid day
%crossover

diffjumps = (abs(t2H(2:end)-t2H(1:end-1))>1);
diffjumps = [diffjumps; 0];
selectorDays = diffjumps.*(1:size(diffjumps,1))';
selectorDays = [0;selectorDays(selectorDays>0,:);size(VarsToTrim,1)];
selector = [];
counter = 0;
while(counter<size(selectorDays,1)-1)
    counter = counter + 1;
    startval = selectorDays(counter,1)+1;
    endval = selectorDays(counter+1,1);
    selector = [selector startval:endval-n]; %#ok<AGROW>
end

trimmedData = VarsToTrim(selector,:);

end

